package com.lanou.activity.Service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.activity.Service.DiscountService;
import com.lanou.activity.mapper.DiscountMapper;
import com.lanou.activity.utils.Constant;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class DiscountServiceImpl implements DiscountService{

    @Resource
    private DiscountMapper discountMapper;

    @Override
    public List<Map<String, Object>> selectConnameByContype(String conType) {
        return discountMapper.selectConnameByContype(conType);
    }

    @Override
    public int addDiscountInfo(Map<String, Object> params) {
        return discountMapper.addDiscountInfo(params);
    }

    @Override
    public PageInfo<Map<String, Object>> selectDiscountByPageList(Map<String, Object> params) {
        Integer currentPage = params.get("currentPage") == null ? 1 : Integer.parseInt((String) params.get("currentPage"));
        PageHelper.startPage(currentPage, Constant.CURRENTPAGE);
        List<Map<String, Object>> list = discountMapper.selectDiscountByPageList(params);
        return new PageInfo<Map<String, Object>>(list);
    }

    @Override
    public List<Map<String, Object>> selectByDisno(String disNo) {
        return discountMapper.selectByDisno(disNo);
    }

    @Override
    public int updateDis(Map<String, Object> params) {
         return  discountMapper.updateDis(params);
    }


}
